/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session.stateless.MRP.MaterialRequirement;

import entity.Ingredient;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Vincent
 */
@Stateless
public class IngredientBean implements IngredientBeanLocal {
    @PersistenceContext (unitName = "M10-IS3102-ejbPU")
    private EntityManager entityManager; 
        
    @Override
    public List<Ingredient> getListOfIngredients(){
        Query query = entityManager.createQuery("SELECT i FROM Ingredient i");
        return query.getResultList();
    }
    
    @Override
    public Ingredient findIngredient(String ingredientName){
        Ingredient ingredient = entityManager.find(Ingredient.class, ingredientName);
        return ingredient;
    }
}
